package com.mccree.service.impl;

import com.mccree.mapper.EmployeeMapper;
import com.mccree.pojo.Employee;
import com.mccree.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {
    final EmployeeMapper employeeMapper;
    @Autowired
    public EmployeeServiceImpl(EmployeeMapper employeeMapper) {
        this.employeeMapper = employeeMapper;
    }

    /**
     * 查询所有员工信息
     */
    public List<Employee> queryEmpList(){
        return employeeMapper.queryEmpList();
    }

    /**
     * 根据id查询员工信息
     * @param id
     * @return
     */
    @Override
    public Employee queryEmpById(Integer id) {
        return employeeMapper.queryEmpById(id);
    }

    /**
     * 根据id修改员工信息
     * @param
     * @return
     */
    @Override
    public Integer updateEmpById(Employee employee) {
        return employeeMapper.updateEmpById(employee);
    }

    /**
     * 插入新的员工信息
     * @param employee
     * @return
     */
    @Override
    public Integer addEmp(Employee employee) {
        return employeeMapper.addEmp(employee);
    }

    /**
     * 根据id删除员工信息
     * @param id
     */
    @Override
    public void removeEmp(Integer id) {
        employeeMapper.removeEmp(id);
    }
}
